#include <bits/stdc++.h>

using namespace std;
const int N = 100001;
int ans1,ans2;
int T;
int n,m,L,V,V_pow2;
int d[N],v[N],a[N],p[N];
bool isCS[N];
int CSYusingtimes[N];
vector<int> f[N];
bool isCSY(int dist)
{
    for(int i=0;i<m;i++)
    {
        if(dist==p[i])
            return true;
    }
    return false;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d%d%d%d",&n,&m,&L,&V);
        V_pow2 = V*V;
        for(int i=0;i<n;i++)
            scanf("%d%d%d",&d[i],&v[i],&a[i]);
        for(int i=0;i<m;i++)
            scanf("%d",&p[i]);

        for(int i=0;i<n;i++)
        {
            if(a==0)
            {
                if(v[i]>V)
                {
                    isCS[i]=1;
                    for(int j=d[i];j<=L;j++)
                    {
                        if(isCSY[j])
                        {
                            f[i].push_back(j);
                            CSYusingtimes[j]++;
                        }
                    }
                }
                continue;
            }
            if(a>0)
            {
                for(int j=d[i];j<=L;j++)
                {
                    if(isCSY(j))
                    {
                        int v1_pow2 = v[i]*v[i]+2*a[i]*(j-d[i]);
                        if(v1_pow2>V_pow2)
                        {
                            isCS[i]=1;
                            f[i].push_back(j);
                            CSYusingtimes[j]++;
                        }
                    }
                }
            }
            else if(a<0)
            {
                if(v[i]<=V)
                    continue;
                int d_stop = d[i]+abs((v[i]*v[i])/(2*a[i]));
                for(int j=d[i];j<=min(d_stop,L);j++)
                {
                    if(isCSY(j))
                    {
                        int v2_pow2 = v[i]+2*a[i]*(j-d[i]);
                        if(v2_pow2<=V_pow2)
                            break;
                        else
                        {
                            isCS[i] = 1;
                            f[i].push_back(j);
                            CSYusingtimes[j]++;
                        }
                    }
                }
            }
        }
        for(int i=0;i<n;i++)
        {
            if(isCS[i])
                ans1++;
        }
        for(int i=0;i<m;i++)
        {
            if(CSYusingtimes[p[i]]==0)
                ans2++;
        }
        int k = m - ans2;
        ans2 += k-(ans1-1);
        printf("%d %d\n",ans1,ans2);
    }
    return 0;
}
